<?php
namespace app\api\controller;

use app\common\service\VaildateService;
use think\cache\driver\Redis;
use think\Controller;
use think\App;
use think\Db;

/**
 *   Date: 2018/12/12
 * Class Base
 * @package app\api\controller
 */
class Base extends Controller
{
    protected $parm;
    protected $redis;
    protected $dev_mode;
    protected $api_config;
    protected $api_url;


    public function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        header("Access-Control-Allow-Origin:*");
        header('Access-Control-Allow-Methods:POST');
        header('Access-Control-Allow-Headers:x-requested-with, content-type,token,company');
        $param = file_get_contents("php://input");
        $this->parm = json_decode($param, true); // 接收传过来的数据
        $this->parm = VaildateService::validateParam($this->parm);//参数过滤
//        $this->parm = input('param.'); //接收参数 请求接口为json传输
        if($this->request->method()!='POST'){
            exit();
        }
        $this->dev_mode = config('api.develop_mode'); // 开发模式
        $this->api_config = config('api_prod.');
        if($this->dev_mode){
            $this->api_config = config('api_dev.');
        }
        $this->api_url = config('api.api_url');
        $this->redis = new Redis($this->api_config['redis']); // 创建一个redis
    }



}